<?php
class UnitTestCase_Unfuddle_Model extends UnitTestCase_Unfuddle {

    public function testNameToClass() {
    
        $name = "foo";
        $this->assertEqual(Unfuddle_Model_Abstract::nameToClass($name), 'Unfuddle_Model_Foo');
        $name = "foO";
        $this->assertEqual(Unfuddle_Model_Abstract::nameToClass($name), 'Unfuddle_Model_Foo');
        $name = "foo-bar";
        $this->assertEqual(Unfuddle_Model_Abstract::nameToClass($name), 'Unfuddle_Model_FooBar');
        $name = "FOO-baR";
        $this->assertEqual(Unfuddle_Model_Abstract::nameToClass($name), 'Unfuddle_Model_FooBar');
    
    }
    
    public function testValueTypes() {
    
        $person = new Unfuddle_Model_Person(array('is-administrator' => true));
        $this->assertEqual($person->getProperty('is-administrator'), true);
        $person = new Unfuddle_Model_Person(array('is-administrator' => 'true'));
        $this->assertEqual($person->getProperty('is-administrator'), true);
        $person = new Unfuddle_Model_Person(array('is-administrator' => false));
        $this->assertEqual($person->getProperty('is-administrator'), false);
        $person = new Unfuddle_Model_Person(array('is-administrator' => 'false'));
        $this->assertEqual($person->getProperty('is-administrator'), false);
    
    }
    
    /**
     * Many of the model fields are read-only, meaning they are returned in the
     * XML when you request a model from the API, but they cannot be updated in
     * any way. One solution for 
     */
    public function testReadOnly() {
    
        // created-at is a read-only field, but I can't just throw an exception
        // when somebody sets its value like this because after reading an xml 
        // response, the ticket model is created using this same method.
        // So how can I restrict certain fields to "read-only"?
        $ticket = new Unfuddle_Model_Ticket(array('created-at' => 'tomorrow'));
    
    }
    
    public function testModelMustValidateOnToXML() {
    
        // $this->expectException();
        // $ticket->toXml();
    
    }
    
    /**
     * It might be kinda cool to use the __call() method to implement getters
     * and setters for property models such as setSummary() and getSummary().
     */
    public function testCallMethodForProperties() {
    
        $ticket = new Unfuddle_Model_Ticket(array('summary' => 'A new ticket'));
        // $this->assertEqual($ticket->getSummary(), 'A new ticket');
    
    }

}